package cn.leelei.spring.test;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.leelei.spring.action.UserAction;

/**
 * 这种现象就是Spring 的IOC 在操作
 * 
 * @author Nike
 *
 */
public class FactorySpring {
	/**
	 * 获得getContext()抽取
	 * 
	 * @return
	 */
	private ApplicationContext getContext() {
		ApplicationContext context = new ClassPathXmlApplicationContext("beans2.xml");
		return context;
	}

	/**
	 * 工厂方法
	 * 1. t通过名称进行获取
	 */
	@Test
	public void getUserAction() {

		UserAction user = (UserAction) getContext().getBean("userAction1");
		user.Save();

	}

}
